const { fork } = require("child_process");
// 父子之间可以发送数据
var childProcess = fork("fork-child.js");

var index = 0;
var intervalId = setInterval(() => {
    index++;
    childProcess.send("this is message from parent process");
    if (ind == 10) {
        clearInterval(intervalId);
    }
}, 2000);

// 接收子进程传来的消息
childProcess.on("message", (chunk) => {
    console.log(chunk);
});
